Skip to content

fix(server): model guidance ranks real evaluations and keeps delegated turns - #129

Merged
ScriptedAlchemy merged 31 commits into
mainfrom
t3/model-guidance-card-fixes
Nov 16, 2026
Merged

ScriptedAlchemy merged 31 commits into
mainfrom
t3/model-guidance-card-fixes

Conversation

@ScriptedAlchemy

@ScriptedAlchemy ScriptedAlchemy commented Nov 16, 2026 •

Copy link
Copy Markdown
Owner

Why

Blind model evaluations reach an orchestrating model only as the modelGuidance card in orchestrator_capabilities. That card showed the weakest data it had. It also lost the orchestrator turns it exists to inform, and it scored work the user never asked for.

An audit of 146 real evaluations found these problems:

  • The card listed groups newest first, so 1-sample groups used up its 6,000-character budget ahead of 5-sample groups.
  • Speed and billing options split one model into several groups. Opus had 7 option variants.
  • Automated wakes were scored as if the user had typed them. Background-command wakes averaged 1.8, against 3.19 for real prompts.
  • All failures shared one generic reason.
  • A turn that delegated work was scored before its child finished. The child's later update then dropped that score for good.

What changed

  • Guidance groups with no scored samples are dropped. The rest are ordered by sample count, then by recency, before the card's limits apply.

  • Groups ignore options that don't change the answer: fastMode, serviceTier, contextWindow and ultracode. Every other option still separates groups, including effort, thinking, OpenCode agent and ACP mode. The card shows the normalized selection it ranked, not the first record's full option set.

  • A run whose request is an automated wake is recorded as skipped and is not judged.

  • A failed evaluation stores its error tag plus one fixed cause: timed out, provider command failed, invalid output, tool activity, provider unavailable or provider request failed. It never stores provider output. An unavailable, missing or unsupported judge, such as the router's "The selected evaluator is unavailable", now counts as provider unavailable. Before, it fell through to provider request failed.

  • A turn with open delegated work waits. It is scored once its children settle, keyed by the child's event revision, so retries and restarts converge.

  • Review follow-ups:

    • A delegated turn whose child settles mid-evaluation is evaluated again, instead of being lost. That covers children that end completed, cancelled or idle.
    • Already-scored automated wakes no longer reach guidance.
    • The refresh stream resubscribes after an error.
    • Evaluation lookups seek the whole event index (stream, run or message id, sequence). readRecords and the refresh query share one source-message check through model_evaluation_message_revision. The refresh scan dropped from about 2.0 s to 0.3 s on a 2.9 GB database.
    • User docs describe pooled options, skipped wakes, delegated work and failure causes.

Scope

  • Covers ranking, grouping, skipping and failure causes, plus delegated turns. Server-side only. The shared reasoning-option list and client effort labels are unchanged.
  • Leaves out pooling across projects, which is the main remaining fragmentation, and a compact card. Changing the card's text needs an eval first.

Blast Radius

Server-side evaluation and guidance only. A read-only count against today's live database finds 60 stored evaluations whose delegated children changed after scoring. All 60 runs have settled. On first start, 59 are re-scored once by the configured evaluator. The other one still has an open child and waits for it. Existing guidance groups that differed only by an agent or mode option now stay separate.

Verification

  • A failing test lands first for each fix. 50 tests pass across ModelEvaluations.test.ts, ModelEvaluationSubagentRefresh.test.ts and modelEvaluation.test.ts. That includes an EXPLAIN QUERY PLAN check that the shared source-message lookup seeks model_evaluation_message_revision on stream, message id and sequence.
  • vp run check:changed passes: format, lint, knip, typecheck for 27 packages, and tests.
  • Live data, read-only: the group and card-entry counts measured before the deny-list change (Opus 7 variants → 3 effort levels, 73 card entries) were not re-measured after it. Options outside the four pooled ones now split groups, so those counts may be higher.
  • Failed runs were already evaluated: one stored row has a failed outcome. That's why this PR doesn't touch that path.

🤖 Generated with Claude Code

ScriptedAlchemy and others added 11 commits November 16, 2026 01:17
The card keeps the newest groups, so an unscored group and twenty one-sample groups leave a five-sample group off it.

Co-authored-by: Cursor <cursoragent@cursor.com>
Newest one-sample groups filled the card before older groups with more scores. Drop groups with no scored samples, then keep the largest groups, newest first.

Co-authored-by: Cursor <cursoragent@cursor.com>
fastMode, serviceTier, contextWindow, and ultracode each open their own group, including fastMode false against an omitted fastMode. Effort values, judges, and turn versus subagent stay separate.

Co-authored-by: Cursor <cursoragent@cursor.com>
fastMode, serviceTier, contextWindow, and ultracode were splitting one model into singleton groups. The selection key keeps effort, reasoningEffort, and reasoning_effort.

Co-authored-by: Cursor <cursoragent@cursor.com>
A command, monitor, group, or delegated-task wake is scored as if the user asked for that work.

Co-authored-by: Cursor <cursoragent@cursor.com>
Command, monitor, group, and delegated-task wakes were judged as user prompts. A request with a notification is recorded as skipped and is not sent to the evaluator.

Co-authored-by: Cursor <cursoragent@cursor.com>
Every evaluator failure is stored as one generic sentence, so a timeout cannot be told from a payload or a response body.

Co-authored-by: Cursor <cursoragent@cursor.com>
Evaluator failures all stored one sentence, so a timeout looked like every other failure. The record keeps the error tag and a short detail, and leaves out the cause payload.

Co-authored-by: Cursor <cursoragent@cursor.com>
Chaining the guidance sort widened confidence to string, and the grouping test passed an undefined subagent flag.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Judging the turn while a child was still running left a score that the child's result then marked stale, and the existing row blocked another pass. Hold the judge until every subagent item has left an active status, then replace that row from the settled evidence.

Co-authored-by: Cursor <cursoragent@cursor.com>
@changeset-bot

changeset-bot Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 293af03

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

ScriptedAlchemy and others added 18 commits November 16, 2026 03:15
…cored

The first evaluation can read an active child and then drop the write when that child settles. Nothing queues a replacement score.

Co-authored-by: Cursor <cursoragent@cursor.com>
A child can settle after the evaluation reads the run and before the write. The write drops that stale packet, and a run with no stored row is never scanned again.

Co-authored-by: Cursor <cursoragent@cursor.com>
Rows scored before wakes were skipped stay in the guidance window. The card still treats them as user prompts.

Co-authored-by: Cursor <cursoragent@cursor.com>
Evaluations stored before wakes were skipped still match the guidance query. A scored or abstaining row whose request is a notification no longer enters that window.

Co-authored-by: Cursor <cursoragent@cursor.com>
A subagent revision lookup constrained event_type with equality, so SQLite could not prove the partial index and scanned the stream index instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
Guidance groups effort, but a boolean thinking flag and thinking_level still share a group with fast mode and context window.

Co-authored-by: Cursor <cursoragent@cursor.com>
Thinking and thinking_level change output quality, but the guidance key only knew three effort ids. Server and client now share one list.

Co-authored-by: Cursor <cursoragent@cursor.com>
The stored cause keeps Claude and Codex command text, including stderr, instead of a short classified reason.

Co-authored-by: Cursor <cursoragent@cursor.com>
The startup scan runs, then a dropped subscription ends the loop. A child that settles afterward is never queued.

Co-authored-by: Cursor <cursoragent@cursor.com>
A single dropped event subscription ended the refresh until the server restarted. The loop logs the failure and subscribes again from the latest cursor.

Co-authored-by: Cursor <cursoragent@cursor.com>
Claude and Codex put command output in the error detail. The saved reason now keeps the error tag and a short cause, not that text.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
AGENTS.md rules out waiting on yieldNow; a Deferred completes when the refresh is queued.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comparing json_extract to a TEXT column applies its affinity, so SQLite used only the index's stream_id column and scanned every thread event. A unary plus on the compared value lets the plan seek stream_id, the run or message id, and sequence, in the refresh query and in readRecords.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dges in model guidance

Agent and mode options must keep their own guidance group, and a group shows the selection it ranked. A child that ends cancelled or idle mid-evaluation must still lead to a score. An unavailable judge must be recorded as such. The source-message check must seek the message-revision index.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tries settling children

Guidance now drops fastMode, serviceTier, contextWindow and ultracode from a selection instead of keeping only effort options, so options like OpenCode agent and ACP mode still separate groups. The card shows that normalized selection. An evaluation retries when a delegated child settles while it runs, and an unavailable judge is classified as provider unavailable. Both evaluation lookups share one indexed source-message check.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The server no longer reads this list, so moving it to packages/shared and adding Pi's thinking option is outside this change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…work

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ScriptedAlchemy
ScriptedAlchemy merged commit 6db75d7 into main Nov 16, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant